<template>
	<view class="container">
		<view class="carousel">
			<swiper circular=true duration="400" @change="swiperChange">
				<swiper-item class="swiper-item" v-for="(item,index) in imgList" :key="index">
					<view class="image-wrapper">
						<image
							:src="item.src" 
							class="loaded" 
							mode="aspectFill"
						></image>
					</view>
				</swiper-item>
			</swiper>
			<view class="swiper-dots">
				<text class="num">{{swiperCurrent+1}}</text>
				<text class="sign">/</text>
				<text class="num">{{swiperLength}}</text>
			</view>
		</view>
		
		<view class="introduce-section">
			
			<view class="i-header">
				<text class="tit clamp">菲律宾菲律宾高地香蕉菲律宾高地香蕉高地香蕉<text>推荐理由</text></text>
			</view>
			<view class="desc">
				<text>Fsdfdf</text>
				<image src="/static/img/1/107.png" mode="scaleToFill"></image>
			</view>
		
			

			
		</view>
		
		
		<view class="c-list" style="padding: 0 0 108upx 0;">
			<view class="c-col b-b">
				<text class="tit">全球唯一身份编码</text>
				<view class="con-list">
					<text>A2019090008848</text>
					
				</view>
			</view>
			<view class="c-row">
				<text class="tit">批次名称</text>
				<view class="con-list">
					<text>菲律宾高地香菲律宾高菲律宾高地香菲律宾高地香蕉菲律宾高地香蕉蕉菲律宾高地香菲律宾高地香蕉菲律宾高地香蕉蕉地香蕉菲律宾高地香蕉蕉</text>
					
				</view>
			</view>
			<view class="c-row">
				<text class="tit">产地</text>
				<view class="con-list">
					<text>菲律宾高地香菲律宾高地香蕉菲律宾高地香蕉蕉</text>
					
				</view>
			</view>
		</view>
		<view class="c-list" style="margin: 10upx 0 20upx 0;">
			<map style="width: 100%; height: 350upx;" :latitude="latitude" :longitude="longitude"></map>
		</view>
		
		
		
		
		
		
			<!-- 详情 -->
		<view class="detail-desc">
			<view class="d-header">
				<text>图文详情</text>
			</view>
			<rich-text :nodes="desc"></rich-text>
		</view>
		
		
		
		
		<!-- 分享 -->
		<share 
			ref="share" 
			:contentHeight="580"
			:shareList="shareList"
		></share>
	</view>
</template>

<script>
	import share from '@/components/share';
	export default{
		components: {
			share
		},
		data() {
			return {
				latitude: 39.909,
				longitude: 116.39742,
				specClass: 'none',
				specSelected:[],
				swiperCurrent:0,
				swiperLength:3,
				favorite: true,
				shareList: [],
				covers: [{
					latitude: 39.9085,
					longitude: 116.39747,
					// #ifdef APP-PLUS
					iconPath: '/static/img/1/107.png',
					// #endif
					// #ifndef APP-PLUS
					iconPath: '/static/img/1/107.png',
					// #endif
				}, {
					latitude: 39.90,
					longitude: 116.39,
					// #ifdef APP-PLUS
					iconPath: '/static/img/1/107.png',
					// #endif
					// #ifndef APP-PLUS
					iconPath: '/static/img/1/107.png',
					// #endif
				}],
				goodsList: [{
						image: "/static/img/8/4.png",
						image2: "http://pic.rmb.bdstatic.com/819a044daa66718c2c40a48c1ba971e6.jpeg",
						image3: "http://img001.hc360.cn/y5/M00/1B/45/wKhQUVYFE0uEZ7zVAAAAAMj3H1w418.jpg",
						title: "日本进口三文鱼",
						price: 179,
						sales: 61,
					},
					{
						image: "/static/img/8/5.png",
						image2: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1554013048&di=a3dc9fd1406dd7bad7fbb97b5489ec04&imgtype=jpg&er=1&src=http%3A%2F%2Fimg009.hc360.cn%2Fhb%2FnKo44ac2656F831c684507E3Da0E3a26841.jpg",
						image3: "http://img.zcool.cn/community/017a4e58b4eab6a801219c77084373.jpg",
						title: "日本进口三文鱼",
						price: 78,
						sales: 16,
					},
					{
						image: "/static/img/8/6.png",
						image2: "http://m.360buyimg.com/n12/jfs/t247/42/1078640382/162559/3628a0b/53f5ad09N0dd79894.jpg%21q70.jpg",
						image3: "http://ikids.61kids.com.cn/upload/2018-12-29/1546070626796114.jpg",
						title: "日本进口三文鱼",
						price: 108.8,
						sales: 5,
					}, {
						image: "/static/img/8/1.png",
						image2: "http://images.jaadee.com/images/201702/goods_img/30150_d85aed83521.jpg",
						image3: "http://img13.360buyimg.com/popWaterMark/jfs/t865/120/206320620/138889/dcc94caa/550acedcN613e2a9d.jpg",
						title: "日本进口三文鱼",
						price: 265,
						sales: 88,
					}, {
						image: "/static/img/8/2.png",
						image2: "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1553418265666&di=d4a7f7eb0ae3c859edeb921641ee1c3a&imgtype=0&src=http%3A%2F%2Fimg003.hc360.cn%2Fy3%2FM02%2FF8%2F9F%2FwKhQh1TuSkGELIlQAAAAAPuLl4M987.jpg",
						image3: "http://img.ef43.com.cn/product/2016/8/05100204b0c.jpg",
						title: "日本进口三文鱼",
						price: 422,
						sales: 137,
					}, {
						image: "/static/img/8/3.png",
						image2: "http://image5.suning.cn/uimg/b2c/newcatentries/0070158827-000000000622091973_2_800x800.jpg",
						image3: "http://img.61ef.cn/news/201903/20/2019032009251784.jpg",
						title: "日本进口三文鱼",
						price: 179,
						sales: 95,
					},
					],
				imgList: [
					{
						src: '/static/img/8/1.png'
					},
					{
						src: '/static/img/8/2.png'
					},
					{
						src: '/static/img/8/3.png'
					}
				],
				desc: `
					<div style="width:100%">
						<img style="width:100%;display:block;" src="/magicdd/static/img/8/1.png" />
						<img style="width:100%;display:block;" src="/magicdd/static/img/8/2.png" />
						<img style="width:100%;display:block;" src="/magicdd/static/img/8/3.png" />
						<img style="width:100%;display:block;" src="/magicdd/static/img/8/4.png" />
						<img style="width:100%;display:block;" src="/magicdd/static/img/8/5.png" />
					</div>
				`
				
			};
		},
		async onLoad(options){
			
			//接收传值,id里面放的是标题，因为测试数据并没写id 
			// let id = options.id;
			// if(id){
			// 	this.$api.msg(`点击了${id}`);
			// }
			
		
			this.shareList = await this.$api.json('shareList');
		},
		methods:{
			//轮播
			
			swiperChange(e) {
				const index = e.detail.current;
				this.swiperCurrent = index;			},
			//溯源
			toTrace(){
				uni.navigateTo({
					url: `/pages/detail/trace`
				})
			},
			//分享
			share(){
				this.$refs.share.toggleMask();	
			},
			
			stopPrevent(){}
		},
		onNavigationBarButtonTap(e) {
			// console.log(e)
			if(e.type === "share"){
				this.$refs.share.toggleMask();
			}else{
				uni.switchTab({
					url: `/pages/index/index`
				})
			}
				
		}

	}
</script>

<style lang='scss'>
	page{
		background: $page-color-base;
		padding-bottom: 160upx;
	}
	.m-t{
		margin-top: 20upx;
	}
	.icon-you{
		font-size: $font-base + 2upx;
		color: #888;
	}
	.carousel {
		height: 722upx;
		position:relative;
		swiper{
			height: 100%;
		}
		.image-wrapper{
			width: 100%;
			height: 100%;
		}
		.swiper-item {
			display: flex;
			justify-content: center;
			align-content: center;
			height: 750upx;
			overflow: hidden;
			image {
				width: 100%;
				height: 100%;
			}
		}
		
	}
	.swiper-dots {
		right: 26upx;
		bottom: 51upx;
		display: flex;
		position: absolute;
		
		width:104upx;
		height:47upx;
		background:rgba(0,0,0,1);
		opacity:0.21;
		border-radius:23upx;
		justify-content: center;
		align-items: center;
	
		.num {
			font-size:23upx;
			font-family:Microsoft YaHei;
			font-weight:400;
			color:rgba(255,255,255,1);
		}
	
		.sign {
			font-size:23upx;
			font-family:Microsoft YaHei;
			font-weight:400;
			color:rgba(255,255,255,1);
		}
	}
	
	/* 标题简介 */
	.introduce-section{
		background: #fff;
		padding: 20upx 30upx;
		.i-header{
			display: flex;
			align-items: center;
			/* height: 70upx; */
			font-size: $font-sm + 2upx;
			color: $font-color-light;
			margin-top: 42upx;
			.tit{
				font-size:31upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(240,64,111,1);
				margin-right: 4upx;
				line-height: 40upx;
				width: 80%;
				text{
					display: block;
					font-size:23upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(102,102,102,1);
					line-height: 40upx;
				}
			}
			.tip{
				flex: 1;
				text-align: right;
				font-size:29upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(77,200,151,1);
				line-height: 40upx;
				text{
					display: block;
					font-size:23upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(102,102,102,1);
					line-height: 40upx;
				}
			}
			.icon-you{
				margin-left: 10upx;
			}
		}
		.desc{
			background:rgba(240,240,240,0);
			/* border:1px solid rgba(200, 200, 200, 1);
			border-radius:10px; */
			padding: 40upx 30upx;
			position: relative;
			margin-top: 11upx;
			image{
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				bottom: 0;
				width: 100%;
				height: 100%;
			}
			text{
				font-size:21upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(102,102,102,1);
				line-height:33upx;
			}
		}
		.full{
			display: flex;
			justify-content: flex-start;
			margin-top: 45upx;
			.f-header{
				width:64upx;
				height:64upx;
				background:rgba(235,74,105,1);
				border-radius:32upx;
				font-size:20upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(255,254,254,1);
				display: flex;
				justify-content: center;
				align-items: center;
				margin-right: 15upx;
			}
			.text-title{
				text{
					display: block;
				}
				.text-large{
					font-size:23upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(102,102,102,1);
					line-height:38upx;
				}
				.text-small{
					font-size:17upx;
					font-family:Microsoft YaHei;
					font-weight:400;
					color:rgba(136,136,136,1);
					line-height:25upx;
				}
			}
		}
			
		.price-box{
			display:flex;
			align-items:baseline;
			height: 64upx;
			padding: 10upx 0;
			font-size: 26upx;
			color:$uni-color-primary;
		}
		.price{
			font-size:51upx;
		}
		.m-price{
			margin:0 12upx;
			color: $font-color-light;
			text-decoration: line-through;
			font-size: 27upx;
		}
		.coupon-tip{
			align-items: center;
			padding: 6upx 18upx;
			border:2upx solid rgba(77, 200, 151, 1);
			border-radius:17upx;
			line-height: 1;
			transform: translateY(-4upx); 
			font-size:25upx;
			font-family:Microsoft YaHei;
			font-weight:400;
			color:rgba(77,200,151,1);
			
		}
		.bot-row{
			display:flex;
			align-items:center;
			height: 50upx;
			font-size: $font-sm;
			color: $font-color-light;
			text{
				flex: 1;
			}
		}
	}
	
	
	.c-list{
		font-size: $font-sm + 2upx;
		color: $font-color-base;
		background: #fff;
		.c-row{
			display:flex;
			align-items:flex-start;
			padding: 20upx 30upx;
			position:relative;
			.radio radio{
				transform:scale(0.6);
			}
			.tit{
				width: 95upx;
				font-size:23upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(68,68,68,1);
				
			}
			.con{
				flex: 1;
				color: $font-color-dark;
				.selected-text{
					margin-right: 10upx;
				}
			}
			.bz-list{
				height: 40upx;
				font-size: $font-sm+2upx;
				color: $font-color-dark;
				text{
					display: inline-block;
					margin-right: 30upx;
				}
			}
			.con-list{
				flex: 1;
				display:flex;
				flex-direction: column;
				font-size:23upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(119,119,119,1);
				margin-left: 34upx;
				
			}
		}
		.c-col{
			padding: 20upx 30upx;
			position: relative;
			.tit{
				flex: 1;
				display: block;
				font-size:23upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(153,153,153,1);
			}
			.con-list{
				display: block;
				font-size:27upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(102,102,102,1);
			}
		}
		
		
		.red{
			color: $uni-color-primary;
		}
	}
	
	
	
	
	/*详情*/
	.detail-desc{
		background: #fff;
		margin-top: 16upx;
		.d-header{
			display: flex;
			justify-content: center;
			align-items: center;
			height: 80upx;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			position: relative;
				
			text{
				padding: 0 20upx;
				background: #fff;
				position: relative;
				z-index: 1;
			}
			&:after{
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translateX(-50%);
				width: 300upx;
				height: 0;
				content: '';
				border-bottom: 1px solid #ccc; 
			}
		}
	}
	
	/* 规格选择弹窗 */
	.attr-content{
		padding: 10upx 30upx;
		.a-t{
			display: flex;
			image{
				width: 170upx;
				height: 170upx;
				flex-shrink: 0;
				margin-top: -40upx;
				border-radius: 8upx;;
			}
			.right{
				display: flex;
				flex-direction: column;
				padding-left: 24upx;
				font-size: $font-sm + 2upx;
				color: $font-color-base;
				line-height: 42upx;
				.price{
					font-size: $font-lg;
					color: $uni-color-primary;
					margin-bottom: 10upx;
				}
				.selected-text{
					margin-right: 10upx;
				}
			}
		}
		.attr-list{
			display: flex;
			flex-direction: column;
			font-size: $font-base + 2upx;
			color: $font-color-base;
			padding-top: 30upx;
			padding-left: 10upx;
		}
		.item-list{
			padding: 20upx 0 0;
			display: flex;
			flex-wrap: wrap;
			text{
				display: flex;
				align-items: center;
				justify-content: center;
				background: #eee;
				margin-right: 20upx;
				margin-bottom: 20upx;
				border-radius: 100upx;
				min-width: 60upx;
				height: 60upx;
				padding: 0 20upx;
				font-size: $font-base;
				color: $font-color-dark;
			}
			.selected{
				background: #fbebee;
				color: $uni-color-primary;
			}
		}
	}
	
	/*  弹出层 */
	.popup {
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		z-index: 99;
		
		&.show {
			display: block;
			.mask{
				animation: showPopup 0.2s linear both;
			}
			.layer {
				animation: showLayer 0.2s linear both;
			}
		}
		&.hide {
			.mask{
				animation: hidePopup 0.2s linear both;
			}
			.layer {
				animation: hideLayer 0.2s linear both;
			}
		}
		&.none {
			display: none;
		}
		.mask{
			position: fixed;
			top: 0;
			width: 100%;
			height: 100%;
			z-index: 1;
			background-color: rgba(0, 0, 0, 0.4);
		}
		.layer {
			position: fixed;
			z-index: 99;
			bottom: 0;
			width: 100%;
			min-height: 40vh;
			border-radius: 10upx 10upx 0 0;
			background-color: #fff;
			.btn{
				height: 66upx;
				line-height: 66upx;
				border-radius: 100upx;
				background: $uni-color-primary;
				font-size: $font-base + 2upx;
				color: #fff;
				margin: 30upx auto 20upx;
			}
		}
		@keyframes showPopup {
			0% {
				opacity: 0;
			}
			100% {
				opacity: 1;
			}
		}
		@keyframes hidePopup {
			0% {
				opacity: 1;
			}
			100% {
				opacity: 0;
			}
		}
		@keyframes showLayer {
			0% {
				transform: translateY(120%);
			}
			100% {
				transform: translateY(0%);
			}
		}
		@keyframes hideLayer {
			0% {
				transform: translateY(0);
			}
			100% {
				transform: translateY(120%);
			}
		}
	}
	
	/* 底部操作菜单 */
	.page-bottom{
		position:fixed;
		/* left: 30upx; */
		bottom:0;
		z-index: 95;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 125upx;
		background: #1B1B1B;
		/* box-shadow: 0 0 20upx 0 rgba(0,0,0,.5); */
		/* border-radius: 16upx; */
		
		.p-b-btn{
			display:flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: $font-sm;
			color: $font-color-base;
			width: 96upx;
			height: 80upx;
			.yticon{
				font-size: 40upx;
				line-height: 48upx;
				color: $font-color-light;
			}
			image{
				width: 50upx;
				height: 50upx;
			}
			&.active, &.active .yticon{
				color: $uni-color-primary;
			}
			.icon-fenxiang2{
				font-size: 42upx;
				transform: translateY(-2upx);
			}
			.icon-shoucang{
				font-size: 46upx;
			}
		}
		.action-btn-group{
			display: flex;
			height: 57upx;
			/* border-radius: 100px; */
			overflow: hidden;
			/* box-shadow: 0 20upx 40upx -16upx #fa436a;
			box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
			background: linear-gradient(to right, #ffac30,#fa436a,#F56C6C); */
			margin-left: 20upx;
			position:relative;
			.action-btn{
				display:flex;
				align-items: center;
				justify-content: center;
				width:172upx;
				height:57upx;
				background:rgba(77,200,151,1);
				border-radius:29upx;
				font-size:25upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(255,255,255,1);
				padding: 0;
			}
			.add-cart-btn{
				background:rgba(237,61,95,1);
				font-size:29upx;
				font-family:Microsoft YaHei;
				font-weight:400;
				color:rgba(255,255,255,1);
				margin-left: 16upx;
			}
		}
	}
	
</style>
